﻿var mysql = require('mysql');
var test_database = 'my_news_test';
var test_table = 'node_user';
//创建连接
var client1 = mysql.createConnection({
    host:'localhost',
    user: 'root',
    password:'123123',
});
client1.connect();
client1.query('use ' + test_database + ';');
client1.query('select * from ' + test_table + ';', function (err, result, fields) {
    if (err) {
        throw err;
    } else if (result) {
        for (var i = 0; i < result.length; i++) {
            console.log('%d\t%s\t%s',result[i].id,result[i].name,result[i].age)
        };
    }
    client1.end();
});